<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>addfriend</title>
		<meta name="author" content="Administrator" />
		<script src="<?php echo base_url();  ?>javascripts/lib/jquery-1.7.min.js"></script>
		<style>
		#fengchao_menu{ width: 200px; height: 800px; float: left; border:  solid 1px #999; margin-top: 5px;}
		#fengchao_1{width: 700px; height: 800px; float: left;}
		#fengchao_title { width: 100% ;height: 80px; float: left; border:  solid 1px #999;}
			.dada{ width:302px; height: 25px; line-height: 25px; font-size: 12px; border:solid 1px #999;  margin-top: 5px; margin-left: 5px;margin-right: 5px;float: left}
			.usertitle{width: 40px;height: 20px;display: block; float: left; margin: 2px; background-color: #666666; color: #fff;  }
			.xingming{width: 80px;height: 25px; display: block; float:left;}
			.anniu{ width: 165px;height: 25px;display: block; float: left;}
			.anniu input{ float: right; font-size: 12px;}
			.key_login{width: 302px;height: 120px; float: left; border: solid 1px #999; padding: 1px; margin: 5px; font-size: 12px; }
			.key_title{ height: 25px;background-color: #666666; color: #fff;margin-bottom: 2px;}
			.key_title input{font-size: 12px;}
			.key_input{height: 25px;}
			.vb1{ width:  100px; height: 25px; line-height:25px; display: block; float: left; text-align: right; }
			.vb2{width: 150px; height: 25px; line-height:25px; display: block; float: left; border-bottom:solid 1px #999;}
			.vb2 li {list-style: none;}
			.menu_button{width: 130px; height: 22px; line-height:22px; font-size: 12px; margin-top: 5px; margin-left: 5px; }
			#showfriend{padding:1px;width: 302px; min-height: 120px;border: solid 1px #999; float: left;margin-top: 5px; margin-right: 5px;margin-left: 5px;font-size: 12px;}
			.inptut_text{ width: 150px; height:  15px; font-size: 12px;border: solid 1px #999; }
			#title111{width: 96%;height: 30px;border: solid 1px #999; padding: 1px; margin: 5px; font-size: 14px; line-height: 30px; background-color: #666666; color: #fff; }
		</style>
		<!-- {"ID":"51","user_email":"3754974@111.com","user_login":"lancer","user_nicename":"lancer","user_city":"","user_img":"","addtime":"132
1945187"} -->
		<script>
			$(function(){
				$("#showfriend,.dada").hide();
				$("#showfriend").click(function() {
					$(this).hide();
					});;
				$(".anniu input").click(function() {					
					var p = $(this ).attr("title");					
					var mobikey = $("#mobikey").val();
					var sessionid = $("#sessionid").val();	
					var ac = $(this).attr("class");
					var action;					
					if(ac == "jiahaoyou"){
						action = "add";
					}else if(ac == "kanzliao"){
						action = "show";
					}	
						$.ajax({
							url:"<?php echo base_url(); ?>sx_friend/",
							data:'mobikey='+mobikey+"&sessionid="+sessionid+"&fid="+p+"&action="+action,
							type:"POST",
							dataType: 'json',
							success:function(i){	
									switch(action){
										case 'add':
											alert(i.Msg);
											break;
										case 'show':
										if(i.Msg){
											alert(i.Msg);
											//alert(i[0].user_login);
										}else{
											$("#showfriend").show();
											$("#showfriend li").html("");
											$("#haoyou1").html(i.user_login);
											$("#haoyou2").html(i.user_email);
											$("#haoyou3").html(i.user_city);
											$("#haoyou4").html(i.user_img);
											$("#haoyou5").html(i.addtime);
										}
											break;
											
									}	
									
							}
						});
						
					});
					$("#showregbutton").click(function(){
							$("#user_reg_div").toggle("slow");
					});
					$("#showloginbutton").click(function(){
							$("#user_login_div").toggle("slow");
					});
					$("#showuserbutton").click(function(){
							$(".dada").toggle("slow");
					});
					$("#showgerenbutton").click(function(){
						if($("#mobikey").val() == ""){
							alert('请登录');
						}else{
							$("#showgerenziliao").toggle("slow").load("<?php echo base_url(); ?>sx_test/geren/"+$("#mobikey").val()+"/"+$("#sessionid").val());
						}
							
					});
					$("#userlogin").click(function() {						
						$.ajax({
							url:"<?php echo base_url(); ?>sx_login/",
							data:'Logininfo='+$("#lusername").val()+"&User_pass="+$("#luserpwd").val()+"&LoginType=0",
							type:"POST",
							dataType: 'json',
							success:function(i){
								//alert(i);
								alert(i.Msg);
								alert(i.Op_id);
								$("#mobikey").val(i.User_mobi_key);
								$("#sessionid").val(i.User_session_id);
								
							}
					});
					});
					$("#userreg").click(function() {
						$.ajax({
							url:"<?php echo base_url(); ?>sx_reg/",
							data:'User_name='+$("#rusername").val()+"&User_pass="+$("#ruserpwd").val()+"&User_mail="+$("#ruseremail").val()+"&Mcode=asdasdasdas",
							type:"POST",
							dataType: 'json',
							success:function(i){
								alert(i.Msg);
								if(i.Msg_error == "0"){									
									$("#mobikey").val(i.User_mobi_key);
									$("#sessionid").val(i.User_session_id);
									$("#lusername").val($("#rusername").val());
									$("#luserpwd").val($("#ruserpwd").val());
									$("#showgerenziliao").show("slow").load("<?php echo base_url(); ?>sx_test/geren/"+$("#mobikey").val()+"/"+$("#sessionid").val());
								}
								
							}
					});
						});
						$("#showallfriendsbutton").click(function(){			
							if($("#mobikey").val() == ""){
								alert("请登录");
								exit();
							}				
							/*$("#showallfriends").toggle("slow").load("<?php echo base_url(); ?>sx_test/allfriend/+$("#mobikey").val()+"/"+$("#sessionid").val());*/
							$("#showallfriends").show("slow").load("<?php echo base_url(); ?>sx_test/allfriend/"+$("#mobikey").val()+"/"+$("#sessionid").val());
						});
					$("#sfriendbutton").click(function(){			
							if($("#mobikey").val() == ""){
								alert("请登录");
								exit();
							}				
							
							$("#sssssfriends").show("slow").load("<?php echo base_url(); ?>sx_test/sf/"+$("#mobikey").val()+"/"+$("#sessionid").val());
						});
						
						$("#addcaipin").click(function() {
								if($("#mobikey").val() == ""){
								alert("请登录");
								exit();
							}		
							window.open("<?=base_url()?>sx_test/addarticle/"+$("#mobikey").val()+"/"+$("#sessionid").val(),"","width=600,height=300");
						});
						$("#shouye").click(function() {
								if($("#mobikey").val() == ""){
								alert("请登录");
								exit();
							}		
							window.open("<?=base_url()?>sx_test/getindex/"+$("#mobikey").val()+"/"+$("#sessionid").val(),"","width=600,height=300");
						});
						$("#zuijin").click(function() {	
							window.open("<?=base_url()?>sx_test/map/","width=600,height=300");
						});
			});
		</script>
		
		<!-- Date: 2011-11-21 -->
	</head>
	<body>
		<div id="fengchao_title">
			
		</div>
		<div id="fengchao_menu">
			<input type="button" value="用户注册" id="showregbutton" class="menu_button" />
			<input type="button" value="用户登录" id="showloginbutton" class="menu_button"  />
			<input type="button" value="查看修改个人信息" id="showgerenbutton" class="menu_button"  />
			<input type="button" value="查看我的好友" id="showallfriendsbutton" class="menu_button"  />
			<input type="button" value="搜索好友" id="sfriendbutton" class="menu_button"  />
			<input type="button" value="添加好友" id="showuserbutton" class="menu_button"  />				
			<input type="button" value="删除好友" id="delfriendbutton" class="menu_button"  />
			<input type="button" value="添加菜品" id="addcaipin" class="menu_button"  />
			<input type="button" value="获取首页" id="shouye" class="menu_button"  />
			<input type="button" value="获取最近" id="zuijin" class="menu_button"  />
		</div>
		<div id="fengchao_1">
		<!-- 个人信息-->
		<div id="showgerenziliao" style="display:none; width: 617px; height: 160px; "  class="key_login"></div>
		<div id="showallfriends" style="display:none; width: 617px; height: 160px; "  class="key_login">我是查看所有好友</div>
		<div id="sssssfriends" style="display:none; width: 617px; height: 160px; "  class="key_login"></div>
		<div class="key_login">
			<div class="key_title">Kye_sessionID</div>	
			<div class="key_input">mobikey&nbsp;:<input type="text" id="mobikey" class="inptut_text" readonly="readonly" /></div>
			<div class="key_input">sessionid:<input type="text" id="sessionid" class="inptut_text" readonly="readonly"/></div>
		</div>
		
		<div id="user_login_div" style="display:none; " >
		<div class="key_login">
			<div class="key_title"><input type="button" id="userlogin"value="用户登录"></div>	
			<div class="key_input">Username:<input type="text" id="lusername" class="inptut_text"  /></div>
			<div class="key_input">UserPwd&nbsp;&nbsp;:<input type="text" id="luserpwd"  class="inptut_text" /></div>
		</div>
		</div>
		<div id="user_reg_div" style="display:none; " >
		<div class="key_login">
			<div class="key_title"><input type="button" id="userreg"value="用户注册"></div>	
			<div class="key_input">Username:<input type="text" id="rusername" class="inptut_text" /></div>
			<div class="key_input">UserEmai&nbsp;:<input type="text" id="ruseremail" class="inptut_text" /></div>
			<div class="key_input">UserPwd&nbsp;&nbsp;:<input type="text" id="ruserpwd" class="inptut_text"  /></div>
		</div>
		</div>
		<div id="showfriend" >
			
				<span class="vb1">用户名：</span><span class="vb2"><li id="haoyou1"></li></span>
				<span class="vb1">邮件地址：</span><span class="vb2"><li id="haoyou2"></li></span>
				<span class="vb1">城市：</span><span class="vb2"><li id="haoyou3"></li></span>
				<span class="vb1">用户头像：</span><span class="vb2"><li id="haoyou4"></li></span>
				<span class="vb1">添加好友时间：</span><span class="vb2"><li id="haoyou5"></li></span>
				<span class="vb1">操作：</span><span class="vb2"><li id="haoyou6"></li></span>
			
		</div>
		<?php foreach($db as $v): ?>
		<div class="dada">
			<span class="usertitle">
				Name:
			</span>
			<span class="xingming"><?=$v['user_login']?></span>
			<span class="anniu">
				<input type="button" value="+好友"  class="jiahaoyou" title="<?=$v['ID']?>" />
				<input type="button" value="+关注"  class="jiaguanzhu" title="<?=$v['ID']?>" />
				<input type="button" value="资料" class="kanzliao" title="<?=$v['ID']?>" />
			</span>
		</div>
		<?php endforeach; ?>
		
		</div>
	</body>
</html>
